<template>
  <div>
    <el-form ref="accountForm" :model="form" label-width="80px">
      <el-row>
        <el-col :md="6" :lg="6">
          <el-form-item label="用户姓名:">
            <el-input
              v-model="form.uname"
              size="medium"
              placeholder="请输入用户姓名"
            />
          </el-form-item>
        </el-col>
        <el-col :md="18" :lg="18" style="text-align: right">
          <el-form-item>
            <el-button
              type="primary"
              size="medium"
              @click="onSubmit('accountForm')"
            >
              搜索
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import mixin from '@/mixin/mixin'
export default {
  name: 'AccountForm',
  mixins: [mixin],
  data() {
    return {
      form: {
        uname: ''
      }
    }
  },
  methods: {
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('on-success-valid', {
            uname: this.form.uname
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
  .el-input{
    width: 160px;
  }
</style>
